]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
SwitcherPopup: Check for type using constructor
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Thu, 18 Apr 2019 20:50:49 +0000 (15:50 -0500)
committerMarco Trevisan (Treviño) <mail@3v1n0.net>
Sat, 27 Apr 2019 01:48:52 +0000 (20:48 -0500)
Classes that are sub-classes of GObject don't use a constructor per se, so we
can't check for new.target (as this is undefined) in _init.

Then compare the current constructor name instead.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/503

js/ui/switcherPopup.js

index c28c22910505ac21fa1f82ee2d9ea80ca8cdb4c3..cd0125786d7e8ecb12d3531772f42f0d668de467 100644 (file)
@@ -33,8 +33,8 @@ function primaryModifier(mask) {
 var SwitcherPopup = GObject.registerClass(
 class SwitcherPopup extends St.Widget {
     _init(items) {
-        if (new.target === SwitcherPopup)
-            throw new TypeError('Cannot instantiate abstract class ' + new.target.name);
+        if (this.constructor.name === SwitcherPopup.prototype.constructor.name)
+            throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
 
         super._init({ style_class: 'switcher-popup',
                       reactive: true,